<!DOCTYPE html>
<html>
  <head>
  	<div th:include="base-libs :: base-libs" />
  	<script th:src="'/quickJs/scripts/easyui/1.5.2/plugins/datagrid-emptyview.js'"></script>
    <title>新建医联体—选择协议</title>
	
    <meta name="keywords" content="keyword1,keyword2,keyword3">
    <meta name="description" content="this is my page">
    <meta name="content-type" content="text/html; charset=UTF-8">
    
    <script>
    	$(function(){
    		initView();
    		$(this).registerManagerPage({
    			cacheTables:["TB_ZY_XYMBLX"],
    			callback: initData
    	    });
    	})
    	
    	function initView(){
    		$("#xyTable").datagrid({
				idField : "XYMBID",
				striped : true,
				clickToSelect: true,
				toolbar : "#tdglFormToolbar",
				fit:true,
				fitColumns:true,
				singleSelect:true,
				border: false,
				view: emptyView,
				emptyMsg: '不存在相关协议',
				columns : [[
						{field : "XYMBID",title : "协议模板编号",width:100,align:'center'},
						{field : "XYMBMC",title : "协议模板名称",width:60,align:'center'},
						{field : "XYMBLX",title : "协议模板类型",width:60,align:'center',formatter: function(value){
                            var TB_ZY_XYMBLX = StoreCache.getCache("TB_ZY_XYMBLX").data;
                            $.each(TB_ZY_XYMBLX, function(){
                                if(this["XMDM"] == value){
                                	value = this["XMMC"];
                                    return false;
                                }
                            })
                            return value;
						}},
// 						{field : "CZ",title : "操作",width:30,formatter: function(value, row, index){
// 							var dgBtn = $("#dgBtn").html();
//                             return dgBtn.replace(/XYMBID/g, row["XYMBID"]);
// 						}}
				]],
				pagination : true,
				pageNumber : 1,
				pageList: [10, 20, 50, 100, 200],
				method : "post",
				onBeforeLoad : function(params) {
					var options = $(this).datagrid('options');
					if(!StringUtils.isEmpty(options.url)){
						params.pageSize = params.rows;
						params.pageNumber = params.page;
					}
				},
				onClickRow : function(index,row){
					
				},
			});
    		
    		/** 确定  */
    		$("#btnQd").click(function(){
    			var select = $("#xyTable").datagrid('getSelected');
    			if(!$.isEmptyObject(select)){
    				StoreCache.setCache("XYMBID", select.XYMBID);
    				$("#btnGb").trigger("click");//关闭 
    			}else{
    				$.QuickAlert.alertFail({content : '请选择一个协议！'});
    			}
    		})
    		
    		/** 关闭  */
    		$("#btnGb").click(function(){
    			parent.layer.closeAll();
    		})
    	}
    	
    	function initData(){
    		$("#xyTable").datagrid({url: contextRoot+"xymb/queryPageXymb.service",});
    	}
    </script>
	
  </head>
  
  <body class="easyui-layout" border="false" fit="true">
    <div region="center" border="false" fit="true">
    	<table id="xyTable"></table>
    </div>
    <div region="south" style="height:40px;line-height:40px;text-align:right;overflow:hidden;border:0;border-top:1px solid #f6f6f6">
    	<button class="btn btn-default" type="button" id="btnQd">确定</button>
    	<button class="btn btn-default" type="button" id="btnGb" style="margin-right:10px;">关闭</button>
    </div>
  </body>
  
  <script type="text/html" id="dgBtn">
      <a class="dgBtn" id=XYMBID href="javascript:void(0)" title="修改" style="color: #00c297;">修改</a>
  </script>
</html>
